package com.jxau.controller;

import com.jxau.controller.utils.Result;
import com.jxau.domain.Admin;
import com.jxau.service.AdminService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/MoviesWebsite/admin")
public class AdminController {
    @Resource
    private AdminService adminService;

    //获取管理员信息
    @GetMapping
    public Result getAdmin(){
        return new Result(true, adminService.list());
    }

    //管理员登录接口
    @PostMapping
    public Result login(@RequestBody Admin admin){
        Boolean flag = adminService.login(admin);
        String data;
        if(flag){
            data = "登录成功";
        }
        else{
            data = "登陆失败";
        }
        return new Result(flag, data);
    }
}
